# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>
# stolen from Archlinux

_realname=docbook-mathml
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.1CR1
pkgrel=4
pkgdesc="MathML XML scheme (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
url="https://www.oasis-open.org/docbook/"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-libxml2")
install=docbook-mathml-${MSYSTEM}.install
source=("https://www.docbook.org/xml/mathml/${pkgver}/dbmathml.dtd" 'LICENSE')
sha256sums=('70da7140035621330f1b5ab6926197c3c3af467f2207d55a41f6396d9ad96abd'
            '57645f7ba4189dfc34f16c08b6bbe041ff298b09cdf57c784bab577bf37ecb24')

package() {
  mkdir -p "$pkgdir${MINGW_PREFIX}/etc/xml"
  ${MINGW_PREFIX}/bin/xmlcatalog --noout --create "${pkgdir}${MINGW_PREFIX}/etc/xml/docbook-mathml"
  
  ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "public" \
      "-//OASIS//DTD DocBook MathML Module V1.1CR1//EN" \
      "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd" \
      "${pkgdir}${MINGW_PREFIX}/etc/xml/docbook-mathml"

  ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "rewriteSystem" \
      "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1" \
      "../../share/xml/docbook/mathml/1.1CR1" \
      "$pkgdir${MINGW_PREFIX}/etc/xml/docbook-mathml"
  ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "rewriteURI" \
      "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1" \
      "../../share/xml/docbook/mathml/1.1CR1" \
      "$pkgdir${MINGW_PREFIX}/etc/xml/docbook-mathml"
  
  install -D -m644 dbmathml.dtd "${pkgdir}${MINGW_PREFIX}/share/xml/docbook/mathml/${pkgver}/dbmathml.dtd"
  install -D -m644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
